/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.gatech.egg.l0cUs.controller.author.admin;

import edu.gatech.egg.l0cUs.domain.Configuration;
import edu.gatech.egg.l0cUs.service.ConfigurationDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 *
 * @author summerspittman
 */
@Controller
@RequestMapping("/admin/**")
public class AdminController {

    @Autowired
    ConfigurationDao configDao;

    @RequestMapping(value = "/admin/index.act", method = RequestMethod.GET)
    public String index(ModelMap modelMap) {
        return "/admin/index";
    }

    @RequestMapping(value = "/admin/index.act", method = RequestMethod.POST)
    public String updateConfiguration(String theme, ModelMap modelMap) {
        Configuration config = configDao.getConfiguration();
        config.setTheme(theme);
        configDao.persist(config);
        return "/admin/index";
    }

}
